from existence import Existence
from experience10 import Experience10
from experimentoutput import pickOtherExperiment
from environmentinput import setEnvironment10, getResultFromEnv10

# Lesson 1 derived Existence class
class Existence10(Existence):
    def __init__(self, steps):
        super().__init__(steps)

    def createTestBench(self):
        setEnvironment10()
        Experience10.clearExperienceDictionary()

    def start(self, randomFlag = False):
        self.createTestBench()

        experiment = ''
        mood = ''
        selfSatisfiedDuration = 0
        cycle = 1

        while cycle < self.steps:
            if mood == 'BORED' or mood == '':
                selfSatisfiedDuration = 0
                experiment = pickOtherExperiment(experiment, randomFlag)

            anticipatedResult = Experience10.anticipate(experiment)
            result = getResultFromEnv10(experiment)

            if result == anticipatedResult:
                mood = 'SELF-SATISFIED'
                selfSatisfiedDuration += 1

                if selfSatisfiedDuration > 3:
                    mood = 'BORED'
            else:
                mood = 'FRUSTRATED'
                selfSatisfiedDuration = 0

            Experience10.recordTuple(experiment, result)

            print(experiment, result, mood, end='\n')
            cycle += 1